import axios from 'axios';

class WFSClient {
  constructor(baseUrl, version = '1.0.0') {
    this.baseUrl = baseUrl;
    this.version = version;
  }

  async getFeature(typeName, filter = null) {
    const params = {
      service: 'WFS',
      version: this.version,
      request: 'GetFeature',
      typeName: typeName
    };
    if (filter) {
      params.filter = filter;
    }

    try {
      const response = await axios.get(this.baseUrl, { params });
      return response.data;
    } catch (error) {
      console.error('Error fetching WFS data:', error);
      throw error;
    }
  }
}

export default WFSClient;
